/**
 * Created by Administrator on 2016/5/4.
 */
(function () {
    angular.module('hearthstone_deck_management')
        .directive('deckCardArea',  ['Decks', function (Decks) {
            return {
                restrict: 'E',
                templateUrl: 'templates/deck_card_area.html',
                scope: {},
                controller: function ($scope) {
                    // 根据json数据文件，初始化所有的卡组信息
                    $scope.decks = Decks.query();

                    // 卡组选择方法
                    this.setDeck = function (deck) {
                        $scope.currentDeck = deck;
                    }

                    // 获取当前选择的卡组
                    this.getDeck = function () {
                        return $scope.currentDeck;
                    }

                    // 添加卡牌
                    this.addCard = function (card) {
                        if(null != $scope.currentDeck) {
                            $scope.currentDeck.cards.push(card);
                        }
                    }
                }
            };
        }])
})();
